package com.feicheng.house.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.feicheng.house.entity.Deposit;
import com.feicheng.house.entity.Record;
import com.feicheng.house.result.ResultInfo;
import com.feicheng.house.service.IDepositService;
import com.feicheng.house.service.IRecordService;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author feichengTech
 * @since 2021-11-06
 */
@RestController
@RequestMapping("/house/deposit")
public class DepositController {
	
	@Autowired
	private IDepositService iDepositService;
	
	/**
	 * 查询押金详情
	 * @param depositId 押金编号 
	 * @return 查询到的押金
	 */
	@GetMapping("/info")
	public ResultInfo getDepositResultInfo(Integer depositId){
		return iDepositService.getDepositInfo(depositId);
	}
	/**
	 * 新增押金
	 * @param deposit 押金对象
	 * @return Boolean值
	 */
	@PostMapping("/info")
	public ResultInfo addDepositResultInfo(Deposit deposit) {
		return iDepositService.addDepositInfo(deposit);
	}
	/**
	 * 修改押金
	 * @param deposit 押金对象
	 * @return Boolean值
	 */
	@PutMapping("/info")
	public ResultInfo editDepositResultInfo(Deposit deposit) {
		return iDepositService.editDepositInfo(deposit);
	}
	/**
	 * 分页查询押金
	 * @param currentPage
	 * @param pageSize
	 * @param searchKey	
	 * @return 查询到的押金和分页
	 */
	@GetMapping("/page")
	public ResultInfo pagesInfo(
	@RequestParam(required = false,defaultValue = "8")Integer pageSize , @RequestParam(required = false,defaultValue = "1")Integer currentPage , String searchKey) {
	return iDepositService.pagesInfo(pageSize, currentPage, searchKey);
	}
	
}

